from time import sleep

from selenium import webdriver

url = 'https://www.baidu.com/'
driver = webdriver.Chrome()
driver.get(url)

print(driver.current_url)
print(driver.window_handles)

# 百度新闻按钮
driver.find_element_by_xpath('//*[@id="s-top-left"]/a[1]').click()

print(driver.current_url)
print(driver.window_handles)

driver.switch_to.window(driver.window_handles[-1])
el_list = driver.find_elements_by_xpath('//*[@id="pane-news"]/div/ul/li/strong/a')
print(len(el_list))